package com.image.request;

import com.image.common_utils.CommonParamCheckUtils;
import com.image.exception.ParamException;

public class GeneralDetectRequest extends AbstractBaseRequest {

	// 黄图识别的类型，是否是url识别
	private boolean isUrl;

	// url
	private String url = "";

	// 图片内容
	private byte[] image;

	public GeneralDetectRequest(String bucketName, String url) {
		super(bucketName);
		this.isUrl = true;
		this.url = url;
	}

	public GeneralDetectRequest(String bucketName, byte[] image) {
		super(bucketName);
		this.isUrl = false;
		this.image = image;
	}

	public boolean isUrl() {
		return isUrl;
	}

	public String getUrl() {
		return url;
	}

	public byte[] getImage() {
		return image;
	}

	@Override
	public void check_param() throws ParamException {
		super.check_param();
		if (isUrl) {
			CommonParamCheckUtils.AssertNotNull("url", url);
		} else {
			CommonParamCheckUtils.AssertNotNull("image content", image);
		}
	}
}
